<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #box {
            width: 280px;
            height: auto;
            margin: 0px auto;
            padding: 0px;
        }

        #title {
            margin: 0px auto;
            text-align: center;
            height: 40px;
            width: 280px;
            background: lightsalmon;
            color: #FFF;
            line-height: 40px;
            cursor: pointer;
        }

        .submenu {
            padding: 0px;
            margin: 0px auto;
            text-align: center;
            width: 280px;
            background: #cccccc;
            color: #666666;
            display: none;
        }

        .submenu li {
            cursor: pointer;
            list-style: none;
            width: 280px;
            text-align: center;
            height: 36px;
            line-height: 32px;
        }
    </style>
</head>
<body>

<div id="box" onmouseleave="hideMenu()">
    <div id="title" onmouseover="showMenu()">课程</div>
    <ul class="submenu">
        <li>后端</li>
        <li>前端</li>
        <li>运维</li>
        <li>UI</li>
    </ul>
</div>

<script>
    function showMenu() {
        console.log('显示菜单....');
        document.getElementsByClassName("submenu")[0].style.display = "block";
    }

    function hideMenu() {
        document.getElementsByClassName("submenu")[0].style.display = "none";
    }
</script>
</body>
</html>
